package com.sanpu.kxe.business.member.adapter;

import android.graphics.Color;
import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sanpu.kxe.R;
import com.sanpu.kxe.business.member.bean.MemberSpreadOutput;
import com.sanpu.kxe.common.interfaces.UrlConstants;
import com.sanpu.kxe.jump.imageloader.JKImageLoader;
import com.sanpu.kxe.module.specialunit.SimplifySpanBuild;
import com.sanpu.kxe.module.specialunit.unit.SpecialTextUnit;

import java.util.ArrayList;

/**
 * Description：会员推广
 * Created by 薛勇军 on 2019/4/12.
 */

public class MemberSpreadAdapter extends BaseQuickAdapter<MemberSpreadOutput, BaseViewHolder> {

    public MemberSpreadAdapter() {
        super(R.layout.item_member_spread, new ArrayList<MemberSpreadOutput>());
    }

    @Override
    protected void convert(BaseViewHolder helper, MemberSpreadOutput item) {
        ImageView levelImagePathIv = helper.getView(R.id.levelImagePathIv);
        TextView levelNameTv = helper.getView(R.id.levelNameTv);
        TextView descriptionTv = helper.getView(R.id.descriptionTv);

        if (item != null) {
            JKImageLoader.getInstance().displayImage(
                    mContext, UrlConstants.getBaseUrl() + item.getLevelImagePath(), levelImagePathIv);
            if (!TextUtils.isEmpty(item.getLevelName())) {
                levelNameTv.setText(item.getLevelName());
            }

            SimplifySpanBuild desBuild = new SimplifySpanBuild(mContext, descriptionTv);
            desBuild.appendSpecialUnit(new SpecialTextUnit("分享", Color.parseColor("#767676")));
            desBuild.appendSpecialUnit(new SpecialTextUnit(item.getDirectNumber() + "", Color.parseColor("#ff3f40")));
            desBuild.appendSpecialUnit(new SpecialTextUnit("人，推广", Color.parseColor("#767676")));
            desBuild.appendSpecialUnit(new SpecialTextUnit(item.getIndirectNumber() + "", Color.parseColor("#ff3f40")));
            desBuild.appendSpecialUnit(new SpecialTextUnit("人", Color.parseColor("#767676")));
            descriptionTv.setText(desBuild.build());
        }
    }
}
